package com.example.home.mvp.view.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.home.R;
import com.example.home.mvp.base.BaseActivity;
import com.example.home.mvp.model.MainModel;
import com.example.home.mvp.model.MainModelImpl;
import com.example.home.mvp.presenter.MainPresenter;
import com.example.home.mvp.view.MainView;

public class HMainActivity extends BaseActivity<MainModel, MainView, MainPresenter> implements MainView {

    private TextView tvFirst;
    private Button mvpBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_mvp);

        tvFirst = findViewById(R.id.tv_show_text);
        mvpBtn = findViewById(R.id.mvp_btn);
        mvpBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                init();
            }
        });

    }

    private void init() {
        if (presenter != null) {
            presenter.getData();
        }
    }


    @Override
    public void setData(String str) {
        tvFirst.setText(str);
    }

//    @Override
//    public void showToast(String info) {
//        Toast.makeText(HMainActivity.this,info,Toast.LENGTH_SHORT).show();
//    }
//
//    @Override
//    public void showProgress() {
//        Toast.makeText(HMainActivity.this,"100",Toast.LENGTH_SHORT).show();
//    }

    @Override
    public MainModel createModel() {
        return new MainModelImpl();
    }

    @Override
    public MainView createView() {
        return this;
    }

    @Override
    public MainPresenter createPresenter() {
        return new MainPresenter();
    }
}
